package com.hy.ssm.controller;

import com.hy.ssm.bean.AdminInfo;
import com.hy.ssm.biz.IAdminInfoBiz;
import com.hy.ssm.mapper.IAdminInfoMapper;
import com.hy.ssm.util.ConstantInfo;
import com.hy.ssm.vo.ResultVO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;

/**
 * @Auther: HuYang
 * @Date: 2022/11/23 - 11 - 23 - 19:23
 * @Description: com.hy.ssm.controller
 * @version: 1.0
 */

@RestController
@RequestMapping("/admin")
public class AdminInfoController {
    @Autowired
    private IAdminInfoBiz adminInfoBiz;

    @PostMapping("/login")
    public ResultVO login(AdminInfo af, HttpSession session){
        AdminInfo admin = adminInfoBiz.login(af);
        if (admin != null){
            session.setAttribute(ConstantInfo.CURRENTLOGINADMIN,admin);
            return new ResultVO(200,"成功!");
        }

        return new ResultVO(500,"失败!");
    }

}
